async function async1() {
  console.log("async1 start");
  // 注意这里 await 后面的内容就相当于一个promise的感觉
  await async2();
  console.log("async1 end");
}

async function async2() {
  console.log("async2");
}

console.log("script start");

setTimeout(() => {
  console.log("setTimeout0");
}, 0);

setTimeout(() => {
  console.log("setTimeout2");
}, 300);

setImmediate(() => console.log("setImmediate"));

process.nextTick(() => console.log("nextTick1"));

async1();

process.nextTick(() => console.log("nextTick2"));

new Promise(function (resolve) {
  console.log("promise1");
  resolve();
  console.log("promise2");
}).then(function () {
  console.log("promise3");
});

console.log("script end");

/**
 * script start
 * async1 start
 * async2
 * async1 end
 * promise1
 * script end
 * nextTick1
 * nextTick2
 * promise3
 * setTimeout0
 * setImmediate
 * setTimeout2
 */

// 出现了很多的错误这样

/**
 * 
 *  这个是答案
    script start
    async1 start
    async2
    promise1
    promise2
    script end
    nextTick1
    nextTick2
    async1 end
    promise3
    setTimeout0
    setImmediate
    setTimeout2
 */
